mruby 4.0.0
mruby is the lightweight implementation of the Ruby language
Loading...
Searching...
No Matches
internal.h File Reference

More...

Go to the source code of this file.

Classes

struct  RBacktrace
 
struct  mrb_backtrace_location
 

Macros

#define MRB_STR_CASECMP_P(str, lit)
 
#define MRB_CI_VISIBILITY(ci)
 
#define MRB_CI_SET_VISIBILITY(ci, visi)
 
#define MRB_CI_VISIBILITY_BREAK_P(ci)
 
#define MRB_CI_SET_VISIBILITY_BREAK(ci)
 

Functions

mrb_value mrb_obj_equal_m (mrb_state *mrb, mrb_value)
 
size_t mrb_packed_int_len (uint32_t num)
 
size_t mrb_packed_int_encode (uint32_t num, uint8_t *p)
 
uint32_t mrb_packed_int_decode (const uint8_t *p, const uint8_t **newpos)
 
void mrb_codedump_all (mrb_state *mrb, struct RProc *proc)
 
void mrb_codedump_all_file (mrb_state *mrb, struct RProc *proc, FILE *out)
 
mrb_value mrb_exc_inspect (mrb_state *mrb, mrb_value exc)
 
mrb_value mrb_exc_backtrace (mrb_state *mrb, mrb_value exc)
 
mrb_value mrb_get_backtrace (mrb_state *mrb)
 
void mrb_exc_mesg_set (mrb_state *mrb, struct RException *exc, mrb_value mesg)
 
mrb_value mrb_exc_mesg_get (mrb_state *mrb, struct RException *exc)
 
mrb_value mrb_f_raise (mrb_state *, mrb_value)
 
mrb_value mrb_make_exception (mrb_state *mrb, mrb_value exc, mrb_value mesg)
 
mrb_value mrb_exc_get_output (mrb_state *mrb, struct RObject *exc)
 
size_t mrb_gc_mark_mt (mrb_state *, struct RClass *)
 
void mrb_gc_free_mt (mrb_state *, struct RClass *)
 
size_t mrb_hash_memsize (mrb_value obj)
 
size_t mrb_gc_mark_hash (mrb_state *, struct RHash *)
 
void mrb_gc_free_hash (mrb_state *, struct RHash *)
 
mrb_value mrb_hash_first_key (mrb_state *, mrb_value)
 
uint32_t mrb_obj_hash_code (mrb_state *mrb, mrb_value key)
 
struct mrb_insn_data mrb_decode_insn (const mrb_code *pc)
 
mrb_value mrb_div_int_value (mrb_state *mrb, mrb_int x, mrb_int y)
 Performs integer division of x by y and returns the result as an mrb_value.
 
mrb_int mrb_div_int (mrb_int x, mrb_int y)
 Performs integer division of x by y.
 
mrb_value mrb_int_add (mrb_state *mrb, mrb_value x, mrb_value y)
 Adds two mrb_values, x and y, where x is expected to be an integer.
 
mrb_value mrb_int_sub (mrb_state *mrb, mrb_value x, mrb_value y)
 Subtracts mrb_value y from mrb_value x, where x is expected to be an integer.
 
mrb_value mrb_int_mul (mrb_state *mrb, mrb_value x, mrb_value y)
 Multiplies two mrb_values, x and y, where x is expected to be an integer.
 
mrb_noreturn void mrb_int_zerodiv (mrb_state *mrb)
 This function is called to raise a ZeroDivisionError.
 
mrb_noreturn void mrb_int_overflow (mrb_state *mrb, const char *reason)
 This function is called to raise a RangeError when an integer operation results in an overflow.
 
void mrb_check_num_exact (mrb_state *mrb, mrb_float num)
 Checks if a mrb_float value is Infinity or NaN.
 
void mrb_gc_free_str (mrb_state *, struct RString *)
 
uint32_t mrb_str_hash (mrb_state *mrb, mrb_value str)
 
mrb_value mrb_str_dump (mrb_state *mrb, mrb_value str)
 
mrb_value mrb_str_inspect (mrb_state *mrb, mrb_value str)
 
mrb_bool mrb_str_beg_len (mrb_int str_len, mrb_int *begp, mrb_int *lenp)
 
mrb_value mrb_str_byte_subseq (mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len)
 
mrb_value mrb_str_aref (mrb_state *mrb, mrb_value str, mrb_value idx, mrb_value len)
 
mrb_bool mrb_strcasecmp_p (const char *s1, mrb_int len1, const char *s2, mrb_int len2)
 
uint32_t mrb_byte_hash (const uint8_t *, mrb_int)
 
uint32_t mrb_byte_hash_step (const uint8_t *, mrb_int, uint32_t)
 
mrb_int mrb_utf8_to_buf (char *buf, uint32_t cp)
 
mrb_value mrb_vm_special_get (mrb_state *, mrb_sym)
 
void mrb_vm_special_set (mrb_state *, mrb_sym, mrb_value)
 
mrb_value mrb_vm_cv_get (mrb_state *, mrb_sym)
 
void mrb_vm_cv_set (mrb_state *, mrb_sym, mrb_value)
 
mrb_value mrb_vm_const_get (mrb_state *, mrb_sym)
 
size_t mrb_obj_iv_tbl_memsize (mrb_value)
 
void mrb_obj_iv_set_force (mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v)
 
mrb_value mrb_mod_constants (mrb_state *mrb, mrb_value mod)
 
mrb_value mrb_mod_const_at (mrb_state *mrb, struct RClass *c, mrb_value ary)
 
mrb_value mrb_f_global_variables (mrb_state *mrb, mrb_value self)
 
mrb_value mrb_obj_instance_variables (mrb_state *, mrb_value)
 
mrb_value mrb_mod_class_variables (mrb_state *, mrb_value)
 
mrb_value mrb_mod_cv_get (mrb_state *mrb, struct RClass *c, mrb_sym sym)
 
mrb_bool mrb_mod_cv_defined (mrb_state *mrb, struct RClass *c, mrb_sym sym)
 
mrb_bool mrb_ident_p (const char *s, mrb_int len)
 
mrb_value mrb_exc_const_get (mrb_state *mrb, mrb_sym sym)
 
void mrb_gc_mark_gv (mrb_state *)
 
void mrb_gc_free_gv (mrb_state *)
 
size_t mrb_gc_mark_iv (mrb_state *, struct RObject *)
 
void mrb_gc_free_iv (mrb_state *, struct RObject *)
 
void mrb_init_shape (mrb_state *)
 
void mrb_free_shape (mrb_state *)
 
mrb_int mrb_ci_bidx (mrb_callinfo *ci)
 
mrb_int mrb_ci_nregs (mrb_callinfo *ci)
 
mrb_value mrb_exec_irep (mrb_state *mrb, mrb_value self, const struct RProc *p)
 
mrb_value mrb_obj_instance_eval (mrb_state *, mrb_value)
 
mrb_value mrb_object_exec (mrb_state *mrb, mrb_value self, struct RClass *target_class)
 
mrb_value mrb_mod_module_eval (mrb_state *, mrb_value)
 
mrb_value mrb_f_send (mrb_state *mrb, mrb_value self)
 
mrb_value mrb_f_public_send (mrb_state *mrb, mrb_value self)
 
struct RBasicmrb_obj_alloc_core (mrb_state *, enum mrb_vtype, struct RClass *)
 

Detailed Description

  • Functions only called from within the library

See Copyright Notice in mruby.h

Macro Definition Documentation

◆ MRB_CI_SET_VISIBILITY

#define MRB_CI_SET_VISIBILITY ( ci,
visi )
Value:
MRB_FLAGS_SET((ci)->vis, 0, 2, visi)

◆ MRB_CI_SET_VISIBILITY_BREAK

#define MRB_CI_SET_VISIBILITY_BREAK ( ci)
Value:
MRB_FLAG_ON((ci)->vis, 2)

◆ MRB_CI_VISIBILITY

#define MRB_CI_VISIBILITY ( ci)
Value:
MRB_FLAGS_GET((ci)->vis, 0, 2)

◆ MRB_CI_VISIBILITY_BREAK_P

#define MRB_CI_VISIBILITY_BREAK_P ( ci)
Value:
MRB_FLAG_CHECK((ci)->vis, 2)

◆ MRB_STR_CASECMP_P

#define MRB_STR_CASECMP_P ( str,
lit )
Value:
mrb_strcasecmp_p(RSTRING_PTR(str), RSTRING_LEN(str), lit, sizeof(lit"")-1)

Function Documentation

◆ mrb_check_num_exact()

void mrb_check_num_exact ( mrb_state * mrb,
mrb_float num )

Checks if a mrb_float value is Infinity or NaN.

If it is, this function raises a FloatDomainError. This is used to prevent conversions of these special float values to exact number types like Integer.

Parameters
mrbThe mruby state.
numThe float value to check. It does not return a value (void function) but will raise an exception if the number is not exact.

◆ mrb_div_int()

mrb_int mrb_div_int ( mrb_int x,
mrb_int y )

Performs integer division of x by y.

This function implements specific rounding behavior for negative numbers to match Ruby's / operator for integers (floor division).

Parameters
xThe dividend.
yThe divisor.
Returns
The result of the integer division (mrb_int). Note: This function does not handle division by zero; the caller is expected to check for this.

◆ mrb_div_int_value()

mrb_value mrb_div_int_value ( mrb_state * mrb,
mrb_int x,
mrb_int y )

Performs integer division of x by y and returns the result as an mrb_value.

It uses mrb_div_int for the division logic.

Parameters
mrbThe mruby state.
xThe dividend.
yThe divisor.
Returns
An mrb_value (integer) representing the result of the division. @raise ZeroDivisionError if y is 0. @raise RangeError for overflow conditions (specifically MRB_INT_MIN / -1).

◆ mrb_int_add()

mrb_value mrb_int_add ( mrb_state * mrb,
mrb_value x,
mrb_value y )

Adds two mrb_values, x and y, where x is expected to be an integer.

y can be an integer, BigInt, Rational, Complex, or Float. The function handles type promotion and dispatches to appropriate handlers.

Parameters
mrbThe mruby state.
xThe first operand (integer).
yThe second operand (can be various numeric types).
Returns
An mrb_value representing the sum. The type of the result depends on the types of the inputs and the magnitude of the result. Handles potential integer overflows by promoting to BigInt if MRB_USE_BIGINT is defined, or raising RangeError otherwise. If y is not a recognized numeric type and MRB_NO_FLOAT is defined, it raises E_TYPE_ERROR. If MRB_NO_FLOAT is not defined, it attempts to convert y to a float.

◆ mrb_int_mul()

mrb_value mrb_int_mul ( mrb_state * mrb,
mrb_value x,
mrb_value y )

Multiplies two mrb_values, x and y, where x is expected to be an integer.

y can be an integer, BigInt, Rational, Complex, or Float. The function handles type promotion and dispatches to appropriate handlers (e.g., mrb_bint_mul for BigInts).

Parameters
mrbThe mruby state.
xThe first operand (integer).
yThe second operand (can be various numeric types).
Returns
An mrb_value representing the product. The type of the result depends on the types of the inputs and the magnitude of the result (e.g., could be Integer, BigInt, Float, Rational, Complex). Handles potential integer overflows by promoting to BigInt if MRB_USE_BIGINT is defined, or raising RangeError otherwise. If y is not a recognized numeric type, it raises E_TYPE_ERROR.

◆ mrb_int_overflow()

mrb_noreturn void mrb_int_overflow ( mrb_state * mrb,
const char * reason )

This function is called to raise a RangeError when an integer operation results in an overflow.

It's marked mrb_noreturn as it always raises an exception and does not return.

Parameters
mrbThe mruby state.
reasonA string describing the operation that caused the overflow (e.g., "addition", "multiplication").

◆ mrb_int_sub()

mrb_value mrb_int_sub ( mrb_state * mrb,
mrb_value x,
mrb_value y )

Subtracts mrb_value y from mrb_value x, where x is expected to be an integer.

y can be an integer, BigInt, Rational, Complex, or Float. The function handles type promotion and dispatches to appropriate handlers.

Parameters
mrbThe mruby state.
xThe minuend (integer).
yThe subtrahend (can be various numeric types).
Returns
An mrb_value representing the difference. The type of the result depends on the types of the inputs and the magnitude of the result. Handles potential integer overflows by promoting to BigInt if MRB_USE_BIGINT is defined, or raising RangeError otherwise. If y is not a recognized numeric type and MRB_NO_FLOAT is defined, it raises E_TYPE_ERROR. If MRB_NO_FLOAT is not defined, it attempts to convert y to a float.

◆ mrb_int_zerodiv()

mrb_noreturn void mrb_int_zerodiv ( mrb_state * mrb)

This function is called to raise a ZeroDivisionError.

It's marked mrb_noreturn as it always raises an exception and does not return.

Parameters
mrbThe mruby state.